package plus.lgx.proj1

object NumberUtils {

  def addOne(ls: List[Int]): List[Int] = addN(ls, 1)

  def addN(ls: List[Int], n: Int): List[Int] = ls.map(_ + n)

  def filterEven(ls: List[Int]): List[Int] = ls.filter(_ % 2 == 0)

  def mapReduce(ls: List[Int])(mapper: Int => Int)(reducer: (Int, Int) => Int): Int = ls.map(mapper).reduce(reducer)

  def main(args: Array[String]): Unit = {
    val list = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

    println(addOne(list))
    println(filterEven(list))
    println(mapReduce(list)(x => x * 2)(_ + _))
  }

}
